#pragma once

// #include "bouffalo_sdk.h"
#include "bflb_gpio.h"
#include "bl616_gpio.h"
#include "bl616_glb.h"
#include "bl616_glb_gpio.h"
#include "../../drivers/lhal/include/hardware/i2c_reg.h"
#include "bflb_i2c.h"
#define lowByte(w) ((uint8_t) ((w) & 0xff))
#define highByte(w) ((uint8_t) ((w) >> 8))

bool getWireTimeoutFlag();
bool clearWireTimeoutFlag();
void setWireTimeout(int timeout, bool reset_on_timeout);
void onRequest(void (*callback)());
void onReceive(void (*callback)(int));
void setClock(int clockFrequency);
int readI2c();
int available();
int write_len(uint8_t *str, int len);
int write_str(uint8_t *str);
int write_char(unsigned char value);
void endTransmission_stop(bool stop);
void endTransmission();
void beginTransmission(unsigned char addr);
int requestFrom_stop(unsigned char addr, int quantity, bool stop);
int requestFrom(unsigned char addr, int quantity);
void end();
void begin_addr(unsigned char addr);
void begin();